//=======================================================================
//功能: 			JavaScript 表情编辑工具类[依赖于jQuery]
//author:		岳静
//e-mail: 		yuejing0129@126.com
//QQ:			503490146
//date: 		2012-07-27
//version: 		1.0
//=======================================================================

var faceUtil = {
		//表情的Json
		faceJson : [{"category":"","common":true,"hot":false,"icon":"http://img.t.sinajs.cn/t35/style/images/common/face/ext/normal/41/zz2_thumb.gif","phrase":"[织]","picid":"","rateLimitLimit":-1,"rateLimitRemaining":-1,"rateLimitReset":-1,"type":"face","url":"http://img.t.sinajs.cn/t35/style/images/common/face/ext/normal/41/zz2_org.gif","value":"[织]"},{"category":"","common":true,"hot":false,"icon":"http://img.t.sinajs.cn/t35/style/images/common/face/ext/normal/60/horse2_thumb.gif","phrase":"[神马]","picid":"","rateLimitLimit":-1,"rateLimitRemaining":-1,"rateLimitReset":-1,"type":"face","url":"http://img.t.sinajs.cn/t35/style/images/common/face/ext/normal/60/horse2_org.gif","value":"[神马]"},{"category":"","common":true,"hot":false,"icon":"http://img.t.sinajs.cn/t35/style/images/common/face/ext/normal/bc/fuyun_thumb.gif","phrase":"[浮云]","picid":"","rateLimitLimit":-1,"rateLimitRemaining":-1,"rateLimitReset":-1,"type":"face","url":"http://img.t.sinajs.cn/t35/style/images/common/face/ext/normal/bc/fuyun_org.gif","value":"[浮云]"},{"category":"","common":true,"hot":false,"icon":"http://img.t.sinajs.cn/t35/style/images/common/face/ext/normal/c9/geili_thumb.gif","phrase":"[给力]","picid":"","rateLimitLimit":-1,"rateLimitRemaining":-1,"rateLimitReset":-1,"type":"face","url":"http://img.t.sinajs.cn/t35/style/images/common/face/ext/normal/c9/geili_org.gif","value":"[给力]"},{"category":"","common":true,"hot":false,"icon":"http://img.t.sinajs.cn/t35/style/images/common/face/ext/normal/f2/wg_thumb.gif","phrase":"[围观]","picid":"","rateLimitLimit":-1,"rateLimitRemaining":-1,"rateLimitReset":-1,"type":"face","url":"http://img.t.sinajs.cn/t35/style/images/common/face/ext/normal/f2/wg_org.gif","value":"[围观]"},{"category":"","common":true,"hot":false,"icon":"http://img.t.sinajs.cn/t35/style/images/common/face/ext/normal/70/vw_thumb.gif","phrase":"[威武]","picid":"","rateLimitLimit":-1,"rateLimitRemaining":-1,"rateLimitReset":-1,"type":"face","url":"http://img.t.sinajs.cn/t35/style/images/common/face/ext/normal/70/vw_org.gif","value":"[威武]"},{"category":"","common":true,"hot":false,"icon":"http://img.t.sinajs.cn/t35/style/images/common/face/ext/normal/6e/panda_thumb.gif","phrase":"[熊猫]","picid":"","rateLimitLimit":-1,"rateLimitRemaining":-1,"rateLimitReset":-1,"type":"face","url":"http://img.t.sinajs.cn/t35/style/images/common/face/ext/normal/6e/panda_org.gif","value":"[熊猫]"},{"category":"","common":true,"hot":false,"icon":"http://img.t.sinajs.cn/t35/style/images/common/face/ext/normal/81/rabbit_thumb.gif","phrase":"[兔子]","picid":"","rateLimitLimit":-1,"rateLimitRemaining":-1,"rateLimitReset":-1,"type":"face","url":"http://img.t.sinajs.cn/t35/style/images/common/face/ext/normal/81/rabbit_org.gif","value":"[兔子]"},{"category":"","common":true,"hot":false,"icon":"http://img.t.sinajs.cn/t35/style/images/common/face/ext/normal/bc/otm_thumb.gif","phrase":"[奥特曼]","picid":"","rateLimitLimit":-1,"rateLimitRemaining":-1,"rateLimitReset":-1,"type":"face","url":"http://img.t.sinajs.cn/t35/style/images/common/face/ext/normal/bc/otm_org.gif","value":"[奥特曼]"},{"category":"","common":true,"hot":false,"icon":"http://img.t.sinajs.cn/t35/style/images/common/face/ext/normal/15/j_thumb.gif","phrase":"[囧]","picid":"","rateLimitLimit":-1,"rateLimitRemaining":-1,"rateLimitReset":-1,"type":"face","url":"http://img.t.sinajs.cn/t35/style/images/common/face/ext/normal/15/j_org.gif","value":"[囧]"},{"category":"","common":true,"hot":false,"icon":"http://img.t.sinajs.cn/t35/style/images/common/face/ext/normal/89/hufen_thumb.gif","phrase":"[互粉]","picid":"","rateLimitLimit":-1,"rateLimitRemaining":-1,"rateLimitReset":-1,"type":"face","url":"http://img.t.sinajs.cn/t35/style/images/common/face/ext/normal/89/hufen_org.gif","value":"[互粉]"},{"category":"","common":true,"hot":false,"icon":"http://img.t.sinajs.cn/t35/style/images/common/face/ext/normal/c4/liwu_thumb.gif","phrase":"[礼物]","picid":"","rateLimitLimit":-1,"rateLimitRemaining":-1,"rateLimitReset":-1,"type":"face","url":"http://img.t.sinajs.cn/t35/style/images/common/face/ext/normal/c4/liwu_org.gif","value":"[礼物]"},{"category":"","common":true,"hot":false,"icon":"http://img.t.sinajs.cn/t35/style/images/common/face/ext/normal/ac/smilea_thumb.gif","phrase":"[呵呵]","picid":"","rateLimitLimit":-1,"rateLimitRemaining":-1,"rateLimitReset":-1,"type":"face","url":"http://img.t.sinajs.cn/t35/style/images/common/face/ext/normal/ac/smilea_org.gif","value":"[呵呵]"},{"category":"","common":true,"hot":false,"icon":"http://img.t.sinajs.cn/t35/style/images/common/face/ext/normal/0b/tootha_thumb.gif","phrase":"[嘻嘻]","picid":"","rateLimitLimit":-1,"rateLimitRemaining":-1,"rateLimitReset":-1,"type":"face","url":"http://img.t.sinajs.cn/t35/style/images/common/face/ext/normal/0b/tootha_org.gif","value":"[嘻嘻]"},{"category":"","common":true,"hot":false,"icon":"http://img.t.sinajs.cn/t35/style/images/common/face/ext/normal/6a/laugh.gif","phrase":"[哈哈]","picid":"","rateLimitLimit":-1,"rateLimitRemaining":-1,"rateLimitReset":-1,"type":"face","url":"http://img.t.sinajs.cn/t35/style/images/common/face/ext/normal/6a/laugh.gif","value":"[哈哈]"},{"category":"","common":true,"hot":false,"icon":"http://img.t.sinajs.cn/t35/style/images/common/face/ext/normal/14/tza_thumb.gif","phrase":"[可爱]","picid":"","rateLimitLimit":-1,"rateLimitRemaining":-1,"rateLimitReset":-1,"type":"face","url":"http://img.t.sinajs.cn/t35/style/images/common/face/ext/normal/14/tza_org.gif","value":"[可爱]"},{"category":"","common":true,"hot":false,"icon":"http://img.t.sinajs.cn/t35/style/images/common/face/ext/normal/af/kl_thumb.gif","phrase":"[可怜]","picid":"","rateLimitLimit":-1,"rateLimitRemaining":-1,"rateLimitReset":-1,"type":"face","url":"http://img.t.sinajs.cn/t35/style/images/common/face/ext/normal/af/kl_org.gif","value":"[可怜]"},{"category":"","common":true,"hot":false,"icon":"http://img.t.sinajs.cn/t35/style/images/common/face/ext/normal/a0/kbsa_thumb.gif","phrase":"[挖鼻屎]","picid":"","rateLimitLimit":-1,"rateLimitRemaining":-1,"rateLimitReset":-1,"type":"face","url":"http://img.t.sinajs.cn/t35/style/images/common/face/ext/normal/a0/kbsa_org.gif","value":"[挖鼻屎]"},{"category":"","common":true,"hot":false,"icon":"http://img.t.sinajs.cn/t35/style/images/common/face/ext/normal/f4/cj_thumb.gif","phrase":"[吃惊]","picid":"","rateLimitLimit":-1,"rateLimitRemaining":-1,"rateLimitReset":-1,"type":"face","url":"http://img.t.sinajs.cn/t35/style/images/common/face/ext/normal/f4/cj_org.gif","value":"[吃惊]"},{"category":"","common":true,"hot":false,"icon":"http://img.t.sinajs.cn/t35/style/images/common/face/ext/normal/6e/shamea_thumb.gif","phrase":"[害羞]","picid":"","rateLimitLimit":-1,"rateLimitRemaining":-1,"rateLimitReset":-1,"type":"face","url":"http://img.t.sinajs.cn/t35/style/images/common/face/ext/normal/6e/shamea_org.gif","value":"[害羞]"},{"category":"","common":true,"hot":false,"icon":"http://img.t.sinajs.cn/t35/style/images/common/face/ext/normal/c3/zy_thumb.gif","phrase":"[挤眼]","picid":"","rateLimitLimit":-1,"rateLimitRemaining":-1,"rateLimitReset":-1,"type":"face","url":"http://img.t.sinajs.cn/t35/style/images/common/face/ext/normal/c3/zy_org.gif","value":"[挤眼]"},{"category":"","common":true,"hot":false,"icon":"http://img.t.sinajs.cn/t35/style/images/common/face/ext/normal/29/bz_thumb.gif","phrase":"[闭嘴]","picid":"","rateLimitLimit":-1,"rateLimitRemaining":-1,"rateLimitReset":-1,"type":"face","url":"http://img.t.sinajs.cn/t35/style/images/common/face/ext/normal/29/bz_org.gif","value":"[闭嘴]"},{"category":"","common":true,"hot":false,"icon":"http://img.t.sinajs.cn/t35/style/images/common/face/ext/normal/71/bs2_thumb.gif","phrase":"[鄙视]","picid":"","rateLimitLimit":-1,"rateLimitRemaining":-1,"rateLimitReset":-1,"type":"face","url":"http://img.t.sinajs.cn/t35/style/images/common/face/ext/normal/71/bs2_org.gif","value":"[鄙视]"},{"category":"","common":true,"hot":false,"icon":"http://img.t.sinajs.cn/t35/style/images/common/face/ext/normal/6d/lovea_thumb.gif","phrase":"[爱你]","picid":"","rateLimitLimit":-1,"rateLimitRemaining":-1,"rateLimitReset":-1,"type":"face","url":"http://img.t.sinajs.cn/t35/style/images/common/face/ext/normal/6d/lovea_org.gif","value":"[爱你]"},{"category":"","common":true,"hot":false,"icon":"http://img.t.sinajs.cn/t35/style/images/common/face/ext/normal/9d/sada_thumb.gif","phrase":"[泪]","picid":"","rateLimitLimit":-1,"rateLimitRemaining":-1,"rateLimitReset":-1,"type":"face","url":"http://img.t.sinajs.cn/t35/style/images/common/face/ext/normal/9d/sada_org.gif","value":"[泪]"},{"category":"","common":true,"hot":false,"icon":"http://img.t.sinajs.cn/t35/style/images/common/face/ext/normal/19/heia_thumb.gif","phrase":"[偷笑]","picid":"","rateLimitLimit":-1,"rateLimitRemaining":-1,"rateLimitReset":-1,"type":"face","url":"http://img.t.sinajs.cn/t35/style/images/common/face/ext/normal/19/heia_org.gif","value":"[偷笑]"},{"category":"","common":true,"hot":false,"icon":"http://img.t.sinajs.cn/t35/style/images/common/face/ext/normal/8f/qq_thumb.gif","phrase":"[亲亲]","picid":"","rateLimitLimit":-1,"rateLimitRemaining":-1,"rateLimitReset":-1,"type":"face","url":"http://img.t.sinajs.cn/t35/style/images/common/face/ext/normal/8f/qq_org.gif","value":"[亲亲]"},{"category":"","common":true,"hot":false,"icon":"http://img.t.sinajs.cn/t35/style/images/common/face/ext/normal/b6/sb_thumb.gif","phrase":"[生病]","picid":"","rateLimitLimit":-1,"rateLimitRemaining":-1,"rateLimitReset":-1,"type":"face","url":"http://img.t.sinajs.cn/t35/style/images/common/face/ext/normal/b6/sb_org.gif","value":"[生病]"},{"category":"","common":true,"hot":false,"icon":"http://img.t.sinajs.cn/t35/style/images/common/face/ext/normal/58/mb_thumb.gif","phrase":"[太开心]","picid":"","rateLimitLimit":-1,"rateLimitRemaining":-1,"rateLimitReset":-1,"type":"face","url":"http://img.t.sinajs.cn/t35/style/images/common/face/ext/normal/58/mb_org.gif","value":"[太开心]"},{"category":"","common":true,"hot":false,"icon":"http://img.t.sinajs.cn/t35/style/images/common/face/ext/normal/17/ldln_thumb.gif","phrase":"[懒得理你]","picid":"","rateLimitLimit":-1,"rateLimitRemaining":-1,"rateLimitReset":-1,"type":"face","url":"http://img.t.sinajs.cn/t35/style/images/common/face/ext/normal/17/ldln_org.gif","value":"[懒得理你]"},{"category":"","common":true,"hot":false,"icon":"http://img.t.sinajs.cn/t35/style/images/common/face/ext/normal/98/yhh_thumb.gif","phrase":"[右哼哼]","picid":"","rateLimitLimit":-1,"rateLimitRemaining":-1,"rateLimitReset":-1,"type":"face","url":"http://img.t.sinajs.cn/t35/style/images/common/face/ext/normal/98/yhh_org.gif","value":"[右哼哼]"},{"category":"","common":true,"hot":false,"icon":"http://img.t.sinajs.cn/t35/style/images/common/face/ext/normal/6d/zhh_thumb.gif","phrase":"[左哼哼]","picid":"","rateLimitLimit":-1,"rateLimitRemaining":-1,"rateLimitReset":-1,"type":"face","url":"http://img.t.sinajs.cn/t35/style/images/common/face/ext/normal/6d/zhh_org.gif","value":"[左哼哼]"},{"category":"","common":true,"hot":false,"icon":"http://img.t.sinajs.cn/t35/style/images/common/face/ext/normal/a6/x_thumb.gif","phrase":"[嘘]","picid":"","rateLimitLimit":-1,"rateLimitRemaining":-1,"rateLimitReset":-1,"type":"face","url":"http://img.t.sinajs.cn/t35/style/images/common/face/ext/normal/a6/x_org.gif","value":"[嘘]"},{"category":"","common":true,"hot":false,"icon":"http://img.t.sinajs.cn/t35/style/images/common/face/ext/normal/af/cry.gif","phrase":"[衰]","picid":"","rateLimitLimit":-1,"rateLimitRemaining":-1,"rateLimitReset":-1,"type":"face","url":"http://img.t.sinajs.cn/t35/style/images/common/face/ext/normal/af/cry.gif","value":"[衰]"},{"category":"","common":true,"hot":false,"icon":"http://img.t.sinajs.cn/t35/style/images/common/face/ext/normal/73/wq_thumb.gif","phrase":"[委屈]","picid":"","rateLimitLimit":-1,"rateLimitRemaining":-1,"rateLimitReset":-1,"type":"face","url":"http://img.t.sinajs.cn/t35/style/images/common/face/ext/normal/73/wq_org.gif","value":"[委屈]"},{"category":"","common":true,"hot":false,"icon":"http://img.t.sinajs.cn/t35/style/images/common/face/ext/normal/9e/t_thumb.gif","phrase":"[吐]","picid":"","rateLimitLimit":-1,"rateLimitRemaining":-1,"rateLimitReset":-1,"type":"face","url":"http://img.t.sinajs.cn/t35/style/images/common/face/ext/normal/9e/t_org.gif","value":"[吐]"},{"category":"","common":true,"hot":false,"icon":"http://img.t.sinajs.cn/t35/style/images/common/face/ext/normal/f3/k_thumb.gif","phrase":"[打哈欠]","picid":"","rateLimitLimit":-1,"rateLimitRemaining":-1,"rateLimitReset":-1,"type":"face","url":"http://img.t.sinajs.cn/t35/style/images/common/face/ext/normal/f3/k_org.gif","value":"[打哈欠]"},{"category":"","common":true,"hot":false,"icon":"http://img.t.sinajs.cn/t35/style/images/common/face/ext/normal/27/bba_thumb.gif","phrase":"[抱抱]","picid":"","rateLimitLimit":-1,"rateLimitRemaining":-1,"rateLimitReset":-1,"type":"face","url":"http://img.t.sinajs.cn/t35/style/images/common/face/ext/normal/27/bba_org.gif","value":"[抱抱]"},{"category":"","common":true,"hot":false,"icon":"http://img.t.sinajs.cn/t35/style/images/common/face/ext/normal/7c/angrya_thumb.gif","phrase":"[怒]","picid":"","rateLimitLimit":-1,"rateLimitRemaining":-1,"rateLimitReset":-1,"type":"face","url":"http://img.t.sinajs.cn/t35/style/images/common/face/ext/normal/7c/angrya_org.gif","value":"[怒]"},{"category":"","common":true,"hot":false,"icon":"http://img.t.sinajs.cn/t35/style/images/common/face/ext/normal/5c/yw_thumb.gif","phrase":"[疑问]","picid":"","rateLimitLimit":-1,"rateLimitRemaining":-1,"rateLimitReset":-1,"type":"face","url":"http://img.t.sinajs.cn/t35/style/images/common/face/ext/normal/5c/yw_org.gif","value":"[疑问]"},{"category":"","common":true,"hot":false,"icon":"http://img.t.sinajs.cn/t35/style/images/common/face/ext/normal/a5/cza_thumb.gif","phrase":"[馋嘴]","picid":"","rateLimitLimit":-1,"rateLimitRemaining":-1,"rateLimitReset":-1,"type":"face","url":"http://img.t.sinajs.cn/t35/style/images/common/face/ext/normal/a5/cza_org.gif","value":"[馋嘴]"},{"category":"","common":true,"hot":false,"icon":"http://img.t.sinajs.cn/t35/style/images/common/face/ext/normal/70/88_thumb.gif","phrase":"[拜拜]","picid":"","rateLimitLimit":-1,"rateLimitRemaining":-1,"rateLimitReset":-1,"type":"face","url":"http://img.t.sinajs.cn/t35/style/images/common/face/ext/normal/70/88_org.gif","value":"[拜拜]"},{"category":"","common":true,"hot":false,"icon":"http://img.t.sinajs.cn/t35/style/images/common/face/ext/normal/e9/sk_thumb.gif","phrase":"[思考]","picid":"","rateLimitLimit":-1,"rateLimitRemaining":-1,"rateLimitReset":-1,"type":"face","url":"http://img.t.sinajs.cn/t35/style/images/common/face/ext/normal/e9/sk_org.gif","value":"[思考]"},{"category":"","common":true,"hot":false,"icon":"http://img.t.sinajs.cn/t35/style/images/common/face/ext/normal/24/sweata_thumb.gif","phrase":"[汗]","picid":"","rateLimitLimit":-1,"rateLimitRemaining":-1,"rateLimitReset":-1,"type":"face","url":"http://img.t.sinajs.cn/t35/style/images/common/face/ext/normal/24/sweata_org.gif","value":"[汗]"},{"category":"","common":true,"hot":false,"icon":"http://img.t.sinajs.cn/t35/style/images/common/face/ext/normal/7f/sleepya_thumb.gif","phrase":"[困]","picid":"","rateLimitLimit":-1,"rateLimitRemaining":-1,"rateLimitReset":-1,"type":"face","url":"http://img.t.sinajs.cn/t35/style/images/common/face/ext/normal/7f/sleepya_org.gif","value":"[困]"},{"category":"","common":true,"hot":false,"icon":"http://img.t.sinajs.cn/t35/style/images/common/face/ext/normal/6b/sleepa_thumb.gif","phrase":"[睡觉]","picid":"","rateLimitLimit":-1,"rateLimitRemaining":-1,"rateLimitReset":-1,"type":"face","url":"http://img.t.sinajs.cn/t35/style/images/common/face/ext/normal/6b/sleepa_org.gif","value":"[睡觉]"},{"category":"","common":true,"hot":false,"icon":"http://img.t.sinajs.cn/t35/style/images/common/face/ext/normal/90/money_thumb.gif","phrase":"[钱]","picid":"","rateLimitLimit":-1,"rateLimitRemaining":-1,"rateLimitReset":-1,"type":"face","url":"http://img.t.sinajs.cn/t35/style/images/common/face/ext/normal/90/money_org.gif","value":"[钱]"},{"category":"","common":true,"hot":false,"icon":"http://img.t.sinajs.cn/t35/style/images/common/face/ext/normal/0c/sw_thumb.gif","phrase":"[失望]","picid":"","rateLimitLimit":-1,"rateLimitRemaining":-1,"rateLimitReset":-1,"type":"face","url":"http://img.t.sinajs.cn/t35/style/images/common/face/ext/normal/0c/sw_org.gif","value":"[失望]"},{"category":"","common":true,"hot":false,"icon":"http://img.t.sinajs.cn/t35/style/images/common/face/ext/normal/40/cool_thumb.gif","phrase":"[酷]","picid":"","rateLimitLimit":-1,"rateLimitRemaining":-1,"rateLimitReset":-1,"type":"face","url":"http://img.t.sinajs.cn/t35/style/images/common/face/ext/normal/40/cool_org.gif","value":"[酷]"},{"category":"","common":true,"hot":false,"icon":"http://img.t.sinajs.cn/t35/style/images/common/face/ext/normal/8c/hsa_thumb.gif","phrase":"[花心]","picid":"","rateLimitLimit":-1,"rateLimitRemaining":-1,"rateLimitReset":-1,"type":"face","url":"http://img.t.sinajs.cn/t35/style/images/common/face/ext/normal/8c/hsa_org.gif","value":"[花心]"},{"category":"","common":true,"hot":false,"icon":"http://img.t.sinajs.cn/t35/style/images/common/face/ext/normal/49/hatea_thumb.gif","phrase":"[哼]","picid":"","rateLimitLimit":-1,"rateLimitRemaining":-1,"rateLimitReset":-1,"type":"face","url":"http://img.t.sinajs.cn/t35/style/images/common/face/ext/normal/49/hatea_org.gif","value":"[哼]"},{"category":"","common":true,"hot":false,"icon":"http://img.t.sinajs.cn/t35/style/images/common/face/ext/normal/36/gza_thumb.gif","phrase":"[鼓掌]","picid":"","rateLimitLimit":-1,"rateLimitRemaining":-1,"rateLimitReset":-1,"type":"face","url":"http://img.t.sinajs.cn/t35/style/images/common/face/ext/normal/36/gza_org.gif","value":"[鼓掌]"},{"category":"","common":true,"hot":false,"icon":"http://img.t.sinajs.cn/t35/style/images/common/face/ext/normal/d9/dizzya_thumb.gif","phrase":"[晕]","picid":"","rateLimitLimit":-1,"rateLimitRemaining":-1,"rateLimitReset":-1,"type":"face","url":"http://img.t.sinajs.cn/t35/style/images/common/face/ext/normal/d9/dizzya_org.gif","value":"[晕]"},{"category":"","common":true,"hot":false,"icon":"http://img.t.sinajs.cn/t35/style/images/common/face/ext/normal/1a/bs_thumb.gif","phrase":"[悲伤]","picid":"","rateLimitLimit":-1,"rateLimitRemaining":-1,"rateLimitReset":-1,"type":"face","url":"http://img.t.sinajs.cn/t35/style/images/common/face/ext/normal/1a/bs_org.gif","value":"[悲伤]"},{"category":"","common":true,"hot":false,"icon":"http://img.t.sinajs.cn/t35/style/images/common/face/ext/normal/62/crazya_thumb.gif","phrase":"[抓狂]","picid":"","rateLimitLimit":-1,"rateLimitRemaining":-1,"rateLimitReset":-1,"type":"face","url":"http://img.t.sinajs.cn/t35/style/images/common/face/ext/normal/62/crazya_org.gif","value":"[抓狂]"},{"category":"","common":true,"hot":false,"icon":"http://img.t.sinajs.cn/t35/style/images/common/face/ext/normal/91/h_thumb.gif","phrase":"[黑线]","picid":"","rateLimitLimit":-1,"rateLimitRemaining":-1,"rateLimitReset":-1,"type":"face","url":"http://img.t.sinajs.cn/t35/style/images/common/face/ext/normal/91/h_org.gif","value":"[黑线]"},{"category":"","common":true,"hot":false,"icon":"http://img.t.sinajs.cn/t35/style/images/common/face/ext/normal/6d/yx_thumb.gif","phrase":"[阴险]","picid":"","rateLimitLimit":-1,"rateLimitRemaining":-1,"rateLimitReset":-1,"type":"face","url":"http://img.t.sinajs.cn/t35/style/images/common/face/ext/normal/6d/yx_org.gif","value":"[阴险]"},{"category":"","common":true,"hot":false,"icon":"http://img.t.sinajs.cn/t35/style/images/common/face/ext/normal/89/nm_thumb.gif","phrase":"[怒骂]","picid":"","rateLimitLimit":-1,"rateLimitRemaining":-1,"rateLimitReset":-1,"type":"face","url":"http://img.t.sinajs.cn/t35/style/images/common/face/ext/normal/89/nm_org.gif","value":"[怒骂]"},{"category":"","common":true,"hot":false,"icon":"http://img.t.sinajs.cn/t35/style/images/common/face/ext/normal/40/hearta_thumb.gif","phrase":"[心]","picid":"","rateLimitLimit":-1,"rateLimitRemaining":-1,"rateLimitReset":-1,"type":"face","url":"http://img.t.sinajs.cn/t35/style/images/common/face/ext/normal/40/hearta_org.gif","value":"[心]"},{"category":"","common":true,"hot":false,"icon":"http://img.t.sinajs.cn/t35/style/images/common/face/ext/normal/ea/unheart.gif","phrase":"[伤心]","picid":"","rateLimitLimit":-1,"rateLimitRemaining":-1,"rateLimitReset":-1,"type":"face","url":"http://img.t.sinajs.cn/t35/style/images/common/face/ext/normal/ea/unheart.gif","value":"[伤心]"}],

		//显示和隐藏的表情的容器ID
		showHideId : undefined,

		//点击表情后是否自动隐藏表情容器[默认为false: 不隐藏]
		isHideInit : false,

		//最大限制输入字数[默认为无限制]
		maxNumInput : undefined,

		//最大限制输入字数显示的控件对象
		maxNumInputObj : undefined,

		//是否使用默认的事件[有onfocus等事件,默认不使用,如果使用则需要在自定义的事件调用faceUtil.getInput()函数]
		isDefaultEvent : false,

		//还可以输入{num}字!
		maxNumInputMsg : '还可以输入{num}字!',

		//已超过{num}字!
		maxNumInputOutstripMsg : '已超过{num}字!',

		//超过字数的执行事件
		maxNumInputOutstripFn : undefined,

		/**
		 * 1.初始化表情容器
		 * @param _data
		 *  _data.showContent : 点击表情显示的控件的ID[默认为'faceContent']
		 *  _data.initContent : 初始化表情到容器的ID[默认为'emotions']
		 *  _data.faceJson    : 表情的Json
		 *  _data.showHideId  : 显示和隐藏的表情的容器ID[不设置默认为initContent的ID]
		 *  _data.isHideInit  : 点击表情后是否自动隐藏表情容器[默认为false: 不隐藏]
		 *  _data.maxNumInput : 最大限制输入字数[默认为无限制]
		 *  _data.maxNumInputId : 最大限制输入字数显示的控件ID
		 *  _data.isDefaultEvent: 是否使用默认的事件[有onfocus等事件,默认不使用]
		 */
		init : function(_data) {

			if(_data === undefined) {
				_data = {};
			}

			if(_data.faceJson != undefined) {
				faceUtil.faceJson = _data.faceJson;
			}

			if(_data.showContent === undefined) {
				_data.showContent = "faceContent";
			}

			if(_data.initContent === undefined) {
				_data.initContent = "emotions";
			}

			if(_data.showHideId === undefined) {
				_data.showHideId = _data.initContent;
			}
			if(_data.maxNumInputMsg != undefined) {
				faceUtil.maxNumInputMsg = _data.maxNumInputMsg;
			}
			if(_data.maxNumInputOutstripMsg != undefined) {
				faceUtil.maxNumInputOutstripMsg = _data.maxNumInputOutstripMsg;
			}
			if(_data.maxNumInputOutstripFn != undefined) {
				faceUtil.maxNumInputOutstripFn = _data.maxNumInputOutstripFn;
			}
			if(_data.maxNumInputFn != undefined) {
				faceUtil.maxNumInputFn = _data.maxNumInputFn;
			}

			//设置是否自动隐藏标签容器
			if(_data.isHideInit != undefined) {
				faceUtil.isHideInit = _data.isHideInit;
			}
			//设置事件
			if(_data.isDefaultEvent != undefined) {
				faceUtil.isDefaultEvent = _data.isDefaultEvent;
			}
			faceUtil.showContent = $("#" + _data.showContent);
			faceUtil.initContent = $("#" + _data.initContent);
			faceUtil.showHideId  = $("#" + _data.showHideId);
			if(_data.maxNumInput != undefined) {
				faceUtil.maxNumInput = _data.maxNumInput;
				if(_data.maxNumInputId != undefined) {
					faceUtil.maxNumInputObj = $("#" + _data.maxNumInputId);
					var _msg = faceUtil.maxNumInputMsg.replace('{num}', faceUtil.maxNumInput);
					faceUtil.maxNumInputObj.html(_msg);
				}
			}

			var result = "";
			jQuery.each(faceUtil.faceJson, function(i, obj){
				result = result + '<li><img title="' + obj.value + '" src="' + obj.url + '"></li>';
			});
			faceUtil.initContent.html(result);

			//给显示的输入框绑定           Chrome 在选中文本域内的文字时，不能触发mouseup事件，导致range依旧为最近一次的range
			if(faceUtil.isDefaultEvent) {
				faceUtil.showContent.focus(function(){
					faceUtil.getInput();
				});
				faceUtil.showContent.mouseup(function(){
					faceUtil.getInput();
				});
				faceUtil.showContent.keyup(function(){
					faceUtil.getInput();
				});
				faceUtil.showContent.mousemove(function(){
					faceUtil.getInput();
				});
			}

			//给li下的img绑定点击事件
			jQuery("#" + _data.initContent + " li img").click(function(){
				setContent(this, _data.showContent);
			});

			/**
			 * 给控件赋值
			 */
			function setContent(_this, _showContent) {

				var range = faceUtil.showContent.attr("range") ? faceUtil.showContent.attr("range").split("|") : [0, 0];

				var startStr = faceUtil.showContent.val().slice(0, range[0]);
				var endStr = faceUtil.showContent.val().slice(range[1]);

				var imgValue = jQuery(_this).attr("title");

				var val = startStr + imgValue + endStr;

				//处理字数限制
				faceUtil.checkInputFn(val);
				/*if(faceUtil.checkInputFn(val)) {
					return;
				}*/

				faceUtil.showContent.val(val);

				var position = parseInt(range[0]) + parseInt(imgValue.length);

				if ($.browser.msie) {
					var range = faceUtil.showContent[0].createTextRange();
					range.collapse(true);
					range.move("character", position);
					range.select();
				}
				else {
					faceUtil.showContent[0].setSelectionRange(position, position);
				}
				//设置光标
				faceUtil.showContent.focus();

				//隐藏表情
				if(faceUtil.isHideInit) {
					faceUtil.hideFace();
				}

			}
		},

		/**
		 * 2.获取显示框光标位置等
		 * 不采用自带的获取光标位置, 需要在onclick/onfocus/onkeyup/onmousemove[可选,控件初始化时,为隐藏则不选]
		 */
		getInput : function() {

			//处理字数限制
			faceUtil.checkInputFn();
			/*if(faceUtil.checkInputFn()) {
				return;
			}*/

			//获取选区
			var start = 0;
			var end = 0;

			if(!document.selection) {
				start = faceUtil.showContent[0].selectionStart;
				end = faceUtil.showContent[0].selectionEnd;
			} else if(document.selection) {
				var range = document.selection.createRange(),
				range_all = document.body.createTextRange(),
				i = 0;

				range_all.moveToElementText(faceUtil.showContent[0]);

				for(; range_all.compareEndPoints("StartToStart", range) < 0; start++) {
					range_all.moveStart('character', 1);
				}

				for(; i<start; i++) {
					if(faceUtil.showContent.val().charAt(i) == "\n") {
						start++;
					}
				}

				range_all = document.body.createTextRange();
				range_all.moveToElementText(faceUtil.showContent[0]);

				for(; range_all.compareEndPoints('StartToEnd', range) < 0; end++) {
					range_all.moveStart('character', 1);
				}

				for(i=0; i <= end; i++) {
					if(faceUtil.showContent.val().charAt(i) == "\n") {
						end++;
					}
				}
			}

			faceUtil.showContent.attr("range", start + "|" + end);
		},

		/**
		 * 3.显示表情集合
		 */
		showFace : function() {
			faceUtil.showHideId.show();
		},

		/**
		 * 4.隐藏表情集合
		 */
		hideFace : function() {
			faceUtil.showHideId.hide();
		},

		/**
		 * 5.处理字数验证函数
		 * @param _val : 输入框的内容
		 */
		checkInputFn : function(_val) {

			if(_val === undefined) {
				_val = faceUtil.showContent.val();
			}
			//处理字数限制
			if(faceUtil.maxNumInput != undefined) {
				var _msg = null;
				var len = faceUtil.getLength(_val);
				if(len > faceUtil.maxNumInput) {
					//设置后会超过字数限制!
					/*var _content = _val.substring(0, faceUtil.maxNumInput);
					if(faceUtil.getLength(_content) < faceUtil.maxNumInput) {
						for(var i = 1; i > 0; i++) {
							_content = _val.substring(0, (faceUtil.maxNumInput + i));
							if(faceUtil.getLength(_content) >= faceUtil.maxNumInput) {
								break;
							}
						}
					}*/
					_msg = faceUtil.maxNumInputOutstripMsg.replace('{num}', (len - faceUtil.maxNumInput) );
					faceUtil.maxNumInputObj.html(_msg);
					if(faceUtil.maxNumInputOutstripFn != undefined) {
						eval(faceUtil.maxNumInputOutstripFn);
					}
					return true;
				}
				_msg = faceUtil.maxNumInputMsg.replace('{num}', (faceUtil.maxNumInput - len) );
				faceUtil.maxNumInputObj.html(_msg);
				if(faceUtil.maxNumInputFn != undefined) {
					eval(faceUtil.maxNumInputFn);
				}
			}
		},

		/**
		 * 6.根据单个表情汉字得到显示的图片路径
		 * @param _value : 表情的汉字
		 */
		getFaceImgPath : function(_value) {
			var _url = undefined;
			$.each(faceUtil.faceJson, function(i, obj){
				if(obj.value === _value) {
					_url = obj.url;
					//退出当前循环
					return false;
				}
			});
			return _url;
		},

		/**
		 * 7.将一组字符串中包含表情汉字的替换为表情
		 * @param _value : 字符串汉字
		 */
		getFaceReplaceAll : function(_value) {
			var index;
			$.each(faceUtil.faceJson, function(i, obj){
				index = _value.indexOf(obj.value);
				while(index > -1) {
					index = _value.indexOf(obj.value);
					_value = _value.replace(obj.value, "<img src='" + obj.url + "'/>");
				}
			});
			return _value;
		},

		/**
		 * 8.得到字符串长度[汉字算一个字, 非汉字算0.5个字]
		 * @param _value
		 */
		getLength : function(_value) {
		    var i, sum;
		    sum = 0;
		    for (i = 0; i < _value.length; i++) {
		        if ((_value.charCodeAt(i) >= 0) && (_value.charCodeAt(i) <= 255))
		            sum = sum + 0.5;
		        else
		            sum = sum + 1;
		    }
		    return Math.round(sum);
		}
};